# -*- coding: utf-8 -*-
import pandas as pd
import os
import shutil


g_tech = "点检表"


def read_sheet(ret, file_path, i):
    df = pd.read_excel(file_path, sheet_name=i)

    for index, row in df.iterrows():
        for name in df.columns:
            if name.find("图片") != -1:
                pic = row[name]
                pic = "%s" % pic
                pic = pic.strip()
                if pic == "nan":
                    continue

                ret.append(pic)


if __name__ == '__main__':
    file_path = "./%s.xlsx" % g_tech

    doc = pd.ExcelFile(file_path)

    ret = []

    for i in doc.sheet_names:
        read_sheet(ret, file_path, i)

    for sn in ret:
        path = "./pic/%s.png" % sn
        if os.path.exists(path):
            continue

        shutil.copy("./pic/empty.png", path)
